//
//  TwoTextLabelCell.m
//  TiantuLogistics
//
//  Created by zhishi.zhaochunlin on 16/5/11.
//  Copyright © 2016年 tiantu. All rights reserved.
//

#import "TwoTextLabelCell.h"

@implementation TwoTextLabelCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.requestLabel.textColor= kPriceColor;
    _titleLabel.textColor = kTextColorTwo;
    self.titleLabel.layer.masksToBounds = self.containerLabel.layer.masksToBounds = self.requestLabel.layer.masksToBounds = YES;
}


- (void)addLeftImage:(NSString *)imageName {
    
    [super updateConstraints];
    
    if (![imageName isEqualToString:@""]) {
        _imageV.hidden = NO;
        self.imageV = [[UIImageView alloc]initWithFrame:CGRectMake(LEFTSPACE, 19, 11, 13)];
        _imageV.image = [UIImage imageNamed:imageName];
        [self.contentView addSubview:_imageV];
        _titleLabel.frame = CGRectMake(CGRectGetMaxX(_imageV.frame), 10, 70, 40);
        
        _leftConstraint.constant = 13.0;
        
    }else {
        _imageV.hidden = YES;
        [_imageV removeFromSuperview];
    }
    
    
    CGRect frame = _titleLabel.frame;
    
    frame.origin.x = _titleLabel.frame.origin.x + 20;
    
    _titleLabel.frame = frame;
}

- (void)addLeftLine:(NSInteger)addType {
    if (addType == 1) {     //  、、出发地
        _leftLineL = [[UILabel alloc]initWithFrame:CGRectMake(20.5, CGRectGetMaxY(_imageV.frame), 1, self.contentView.frame.size.height-CGRectGetMaxY(_imageV.frame)+5)];
        
        
    }else if (addType == 2){   // 目的地
        _leftLineL = [[UILabel alloc]initWithFrame:CGRectMake(20.5, 0, 1, CGRectGetMinY(_imageV.frame)-7)];
        
    }else {  //全部
        _leftLineL = [[UILabel alloc]initWithFrame:CGRectMake(20.5, -15, 1, self.contentView.frame.size.height+5)];
        
    }
//    _leftLineL.backgroundColor = kBackGColor;
    [self.contentView addSubview:self.leftLineL];
    
    
    CAShapeLayer *shapeLayer = [CAShapeLayer layer];
    [shapeLayer setBounds:_leftLineL.bounds];
    [shapeLayer setPosition:CGPointMake(CGRectGetWidth(_leftLineL.frame), CGRectGetHeight(_leftLineL.frame))];
    [shapeLayer setFillColor:[[UIColor clearColor] CGColor]];
    // 设置虚线颜色为blackColor
    [shapeLayer setStrokeColor:kBackGColor.CGColor];
    // 3.0f设置虚线的宽度
    [shapeLayer setLineWidth:CGRectGetWidth(_leftLineL.frame)];
    [shapeLayer setLineJoin:kCALineJoinRound];
    // 3=线的宽度 1=每条线的间距
    [shapeLayer setLineDashPattern:[NSArray arrayWithObjects:@(3),@(1),nil]];
    
    CGMutablePathRef path = CGPathCreateMutable(); //Setup the path
    CGPathMoveToPoint(path, NULL, 0, -5);
    CGPathAddLineToPoint(path, NULL, 0,CGRectGetHeight(_leftLineL.frame));
    // Setup the path CGMutablePathRef path = CGPathCreateMutable(); // 0,10代表初始坐标的x，y
    // 320,10代表初始坐标的x，y CGPathMoveToPoint(path, NULL, 0, 10);
    //        CGPathAddLineToPoint(path, NULL, 320,10);
    [shapeLayer setPath:path];
    CGPathRelease(path);
    [_leftLineL.layer addSublayer:shapeLayer];
}


- (void)setLabelText:(NSString *)text {
    self.titleLabel.text = text;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

-(void)drawRect:(CGRect)rect

{
    
    
    
    
}

@end
